﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Toep
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //矩阵转数组，行数对应一维数组长度，列数对应二维数组长度
            Console.WriteLine("请输入矩阵的行数：");
            int m = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入矩阵的列数：");
            int n = int.Parse(Console.ReadLine());

            Console.WriteLine("请输入矩阵：");
            //矩阵转二维数组：
            int[,] matrix = new int[m, n];
            for (int i = 0; i < m; i++)
            {
                string[] row = Console.ReadLine().Trim('|').Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
                for (int j = 0; j < n; j++)
                {
                    matrix[i, j] = int.Parse(row[j]);
                }
            }

            //接下来开始检验
            bool IsToeplitzMatrix(int[,] test)
            {
                int m1 = test.GetLength(0);//行数
                int n1 = test.GetLength(1);//列数
                for (int i = 1; i < m1; i++)
                {
                    for (int j = 1; j < n1; j++)
                    {
                        if (test[i, j] != test[i - 1, j - 1])
                        {
                            return false;
                        }
                    }
                }
                return true;
            }

            if (IsToeplitzMatrix(matrix))
            { Console.WriteLine("True"); }
            else 
            { Console.WriteLine("False"); }

            Console.ReadLine();
        }
    }
}
